package com.usian.controller;

import com.usian.feign.TbItemFeign;
import com.usian.pojo.TbItemCat;
import com.usian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author chen
 * @date 2021/1/9 - 19:14 - 星期六
 * @project usian_parent
 * @package com.usian.controller
 * @by GGbomd猪猪侠
 */
@RestController
@RequestMapping("/backend/itemCategory")
public class TbItemCatControllerWeb {

    @Autowired
    private TbItemFeign tbItemFeign;

    /**
     * 查询分类表 根据父节点查询子节点
     * @param id
     * @return
     */
    @RequestMapping("/selectItemCategoryByParentId")
    public Result selectItemCategoryByParentId(@RequestParam(defaultValue = "0") Long id){
        List<TbItemCat> tbItemCatList = tbItemFeign.selectItemCategoryByParentId(id);
        //判断查出来的集合有没有数据
        if (tbItemCatList != null && tbItemCatList.size() > 0){
            return Result.ok(tbItemCatList);
        }
        return Result .error("查无结果");
    }

}
